package edu.clemson.wcbeck.cft;

//import java.sql.Date;

import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;

public class MediaFile implements Parcelable{

	private int id, teamid;
	private String name, location, comment = "n/a";
	private float gps_lat, gps_lon;
	private int mediaType, isStock, isUploaded;
	private String date_time;				//have this be a date?
	private static final String[] MEDIA = {"image","video","audio"};
	
	public MediaFile() {}
	
	public MediaFile(Parcel in){
		readFromParcel(in);
	}
	
	public int getId(){
		return id;
	}
	
	public void setId(int id){
		this.id = id;
	}
	
	public int getTeamid(){
		return teamid;
	}
	
	public void setTeamid(int teamid){
		this.teamid = teamid;
	}
	
	public String getName(){
		return name;
	}
	
	public void setName(String name){
		this.name = name;
	}
	
	public String getLocation(){
		return location;
	}
	
	public void setLocation(String location){
		this.location = location;
	}
	
	public String getComment(){
		return comment;
	}
	
	public void setComment(String comment){
		this.comment = comment;
	}
	
	public float getGps_Lat(){
		return gps_lat;
	}
	
	public void setGps_Lat(float gps_lat){
		this.gps_lat = gps_lat;
	}
	
	public float getGps_Lon(){
		return gps_lon;
	}
	
	public void setGps_Lon(float gps_lon){
		this.gps_lon = gps_lon;
	}
	
	public int getMediaType(){
		return mediaType;
	}
	
	public void setMediaType(int mediaType){
		this.mediaType = mediaType;
	}
	
	public int getIsStock(){
		return isStock;
	}
	
	public void setIsStock(int isStock){
		this.isStock = isStock;
	}
	
	public int getIsUploaded(){
		return isUploaded;
	}
	
	public void setIsUploaded(int isUploaded){
		this.isUploaded = isUploaded;
	}
	
	public String getDate_Time(){
		return date_time;
	}
	
	public void setDate_Time(String date_time){
		this.date_time = date_time;
	}
	
	private void readFromParcel(Parcel in) {
		 
		id = in.readInt();
		teamid = in.readInt();
		name = in.readString();
		location = in.readString();
		comment = in.readString();
		gps_lat = in.readFloat();
		gps_lon = in.readFloat();
		mediaType = in.readInt();
		isStock = in.readInt();
		isUploaded = in.readInt();
		date_time = in.readString();
	}
	
	@Override
	public String toString(){
		return MEDIA[mediaType] + " - " + name;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		
		dest.writeInt(id);
		dest.writeInt(teamid);
		dest.writeString(name);
		dest.writeString(location);
		dest.writeString(comment);
		dest.writeFloat(gps_lat);
		dest.writeFloat(gps_lon);
		dest.writeInt(mediaType);
		dest.writeInt(isStock);
		dest.writeInt(isUploaded);
		dest.writeString(date_time);
	}
	
	public ContentValues mediaToConVal(){
		ContentValues values = new ContentValues();
		
		values.put("teamid", this.getTeamid());
		values.put("name", this.getName());
		values.put("location",this.getLocation());
		values.put("comment", this.getComment());
		values.put("gps_lat", this.getGps_Lat());
		values.put("gps_lon", this.getGps_Lon());
		values.put("mediaType", this.getMediaType());
		values.put("isStock", this.getIsStock());
		values.put("isUploaded", this.getIsUploaded());
		values.put("date_time", this.getDate_Time());
		
		return values;
	}
	
	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR =
	new Parcelable.Creator() {
		public MediaFile createFromParcel(Parcel in) {
			return new MediaFile(in);
		}

		public MediaFile[] newArray(int size) {
			return new MediaFile[size];
		}
	};

}
